package com.ojoin.trade.supplyloan_core.web.service.renew;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.ojoin.trade.common.CallBack;
import com.ojoin.trade.common.web.domain.BaseEntity;
import com.ojoin.trade.common.web.domain.Dict;
import com.ojoin.trade.common.web.service.DictService;
import com.ojoin.trade.supplyloan_core.web.domain.TbSlPlatformUser;
import com.ojoin.trade.supplyloan_core.web.service.TbSlPlatformUserService;

@Component
public class SupplyUpDownContractRenew implements CallBack{

	@Autowired
	private  DictService dictService;
	
	@Autowired
	private TbSlPlatformUserService platformUserService;
	
	@Override
	public void updateHandle(Map arg) {
		Integer joinUserId = (Integer) arg.get("joinUserId");
		Integer fileId = (Integer) arg.get("fileId");
		Integer platformId = Integer.parseInt((String) arg.get("renewType"));
		String expiredDate = (String) arg.get("expiredDate");

		Dict dict = new Dict();
		dict.setId((Integer) (arg.get("dictId")));
		dict.setDelFlag(BaseEntity.DEL_FLAG_DELETE);
		dictService.delete(dict);

		TbSlPlatformUser platformUser = new TbSlPlatformUser();
		platformUser.setId(platformId);
		platformUser.setContractExpireDate(expiredDate);
		platformUser.setBusiContract(String.valueOf(fileId));
		
		platformUserService.updateByIdSelective(platformUser);

	}

}
